home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
network
/
exp16116.zip
/
TAIL.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-12-22
|
17KB
|
651 lines
; PC/FTP Packet Driver source, conforming to version 1.05 of the spec
; Updated to version 1.08 Feb. 17, 1989.
; Copyright 1988-1993 Russell Nelson
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, version 1.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include defs.asm
code segment word public
assume cs:code, ds:code
public is_eisa
is_eisa db 0 ;=0 if ISA, =1 if EISA
extrn sys_features: byte ;bitmask of system features.
extrn is_186: byte ;=0 if 808[68], =1 if 80[1234]86.
extrn is_286: byte ;=0 if 80[1]8[68], =1 if 80[234]86.
extrn is_386: byte ;=0 if 80[12]8[68], =1 if 80[34]86.
extrn int_no: byte ;the board's interrupt level.
extrn hw_int_no: byte ;the 8259 interrupt level.
extrn driver_class: byte ;the class of this driver, per the spec.
extrn rcv_modes: word ;count of modes followed by mode handles.
;-> last byte of static memory used by driver-dependent code.
extrn end_resident: byte
extrn end_free_mem: byte
;-> the fixed address of the card.
extrn rom_address: byte
;-> the current address of the card.
extrn my_address: byte
extrn phd_dioa: byte
extrn phd_environ: word
extrn flagbyte: byte
include printnum.asm
include decout.asm
include digout.asm
include crlf.asm
include chrout.asm
free_mem dw end_resident ;allocate memory from here.
;also see memory_to_keep.
public malloc
malloc:
;enter with dx = amount of memory desired.
;exit with nc, dx -> that memory, or cy if there isn't enough memory.
add dx,free_mem ;make a pointer after that much memory.
cmp dx,offset end_free_mem ;is it still in the free area?
ja malloc_1 ;no, we're in trouble.
xchg dx,free_mem ;get the pointer back, store ptr->end.
clc
ret
malloc_1:
stc
ret
end_tail_1 label byte ; end of the delayed init driver
;usage_msg is of the form "usage: driver [options] <packet_int_no> <args>"
extrn usage_msg: byte
options_i_msg label byte
db" -i -- Force driver to report itself as IEEE 802.3 instead of Ethernet II.",CR,LF
options_msg label byte
db" -d -- Delayed initialization. Used for diskless booting",CR,LF
db" -n -- NetWare conversion. Converts 802.3 packets into 8137 packets",CR,LF
db" -w -- Windows hack, obsoleted by winpkt",CR,LF
db" -p -- Promiscuous mode disable",CR,LF
db" -u -- Uninstall",CR,LF
db '$'
;copyright_msg is of the form:
;"Packet driver for the foobar",CR,LF
;"Portions Copyright 19xx, J. Random Hacker".
extrn copyright_msg: byte
copyleft_msg label byte
db "Packet driver skeleton copyright 1988-93, Crynwr Software.",CR,LF
db "This program is freely copyable; source must be available; NO WARRANTY.",CR,LF
db "See the file COPYING.DOC for details; send FAX to +1-315-268-9201 for a copy.",CR,LF
db CR,LF,'$'
no_resident_msg label byte
db CR,LF,"*** Packet driver failed to initialize the board ***",CR,LF,'$'
;parse_args should parse the arguments.
;called with ds:si -> immediately after the entry_point.
extrn parse_args: near
;print_parameters should print the arguments.
extrn print_parameters: near
extrn our_isr: near, their_isr: dword
extrn entry_point: byte
eisa_signature db "EISA"
system_msg db "System: ",'$'
i386_msg db "[345]86 processor",'$'
i286_msg db "286 processor",'$'
i186_msg db "186 processor",'$'
i8088_msg db "8088/8086 processor",'$'
mca_msg db ", Microchannel bus",'$'
eisa_msg db ", EISA bus",'$'
isa_msg db ", ISA bus",'$'
two_8259_msg db ", Two 8259s",'$'
entry_point_name db "Packet driver software interrupt is ",'$'
eaddr_msg db "My Ethernet address is ",'$'
aaddr_msg db "My ARCnet address is ",'$'
already_msg db CR,LF,"Error: there is already a packet driver (you may uninstall it using -u) at ",'$'
no_pkint_msg db CR,LF,"Error: there is no packet driver at ",'$'
no_pkt_msg db CR,LF,"Error: no packet driver found between 0x60 and 0x80",CR,LF,'$'
two_pkts_msg db CR,LF,"Error: there are two packets drivers (specify the desired one after -u).",CR,LF,'$'
int_msg db CR,LF
db "Error: <hardware_irq> should be between 0 and "
int_msg_num label word
db "15 inclusive", '$'
xt_hd_warn_msg db CR,LF,"Warning: the hard disk on an XT usually uses IRQ 5. Use a different interrupt",CR,LF,'$'
no_ieee_msg db CR,LF,"Error: this driver doesn't implement both IEEE 802.3 and Ethernet II",CR,LF,'$'
terminated_msg db "Uninstall completed",'$'
handle dw ?
entry_point_fnd db 0
bogus_type db 0,0 ;totally bogus type code.
our_recv:
xor di,di
mov es,di
retf
public etopen_diagn
etopen_diagn db 0 ; errorlevel from etopen if set
;etopen should initialize the device. If it needs to give an error, it
;can issue the error message and quit to dos.
extrn etopen: near
memory_to_keep dw end_resident ;keep at least this much memory.
;also see free_mem.
already_error:
mov dx,offset already_msg
already_error_1:
mov di,offset entry_point
call print_number
mov ax,4c05h ; give errorlevel 5
int 21h
usage_error:
mov dx,offset usage_msg
mov ah,9
int 21h
mov dx,offset options_msg
cmp word ptr driver_class,BLUEBOOK + IEEE8023*256 ;both present?
jne error
mov dx,offset options_i_msg
public error
error:
mov ah,9
int 21h
mov ax,4c0ah ; give errorlevel 10
int 21h
;;; include timeout.asm
public start_1
start_1:
cld
mov dx,offset copyright_msg
mov ah,9
int 21h
mov dx,offset copyleft_msg
mov ah,9
int 21h
mov dx,offset branding_msg
mov ah,9
int 21h
mov dx,0f000h ;ROM segment
mov es,dx
mov di,0ffd9h
mov si,offset eisa_signature
mov cx,2
repe cmpsw
jne not_eisa
inc is_eisa
not_eisa:
;
; Get the feature byte (if reliable) so we can know if it is a microchannel
; computer and how many interrupts there are.
;
mov ah,0c0h
int 15h ; es:bx <- sys features block
jc look_in_ROM ; error, must use rom.
or ah,ah
jnz look_in_ROM
mov dx,es:[bx] ; # of feature bytes
cmp dx,4 ; do we have the feature byte we want?
jae got_features ;yes.
look_in_ROM:
cmp byte ptr es:[0fffeh],0fch;is this an AT?
jne identified ;no.
or sys_features,TWO_8259 ; ATs have 2nd 8259
jmp short identified ; assume no microchannel
got_features:
mov ah,es:[bx+2] ; model byte
cmp ah,0fch
je at_ps2
ja identified ; FD, FE and FF are not ATs
cmp ah,0f8h
je at_ps2
ja identified ; F9, FA and FB are not ATs
cmp ah,09ah
jbe identified ; old non-AT Compacs go here
at_ps2: ; 9B - F8 and FC are assumed to
mov ah,es:[bx+5] ; have reliable feature byte
mov sys_features,ah
identified:
;Determine the processor type. The 8088 and 8086 will actually shift ax
;over by 33 bits, while the 80[123]86 use a shift count mod 32.
mov cl,33
mov ax,0ffffh
shl ax,cl ;186 or better?
jz processor_identified ;no.
mov is_186,1
push sp
pop ax
cmp ax,sp ;286 or better?
jne processor_identified ;no.
mov is_286,1
pushf
pop ax
or ax,7000h ;the 386 lets us set these bits
push ax
popf ;this should be a real popf.
pushf
pop ax
test ax,7000h ;did the bits get set?
je processor_identified
mov is_386,1
processor_identified:
mov si,offset phd_dioa+1
call skip_blanks ;end of line?
cmp al,CR
je usage_error_j_1
chk_options:
call skip_blanks
cmp al,'-' ; any options?
jne no_more_opt
inc si ; skip past option char
lodsb ; read next char
or al,20h ; convert to lower case
cmp al,'d'
jne not_d_opt
or flagbyte,D_OPTION
jmp chk_options
not_d_opt:
cmp al,'n'
jne not_n_opt
or flagbyte,N_OPTION
jmp chk_options
not_n_opt:
cmp al